# Maintainer(Arch): Zhuoyun Wei <wzyboy@wzyboy.org>
# Contributor: "Amhairghin" Oscar Garcia Amor (https://ogarcia.me)
# Maintainer : Sagar Acharya <sagar@hyperbola.info>

pkgname=python-magic
pkgdesc='A python wrapper for libmagic'
pkgver=0.4.20
pkgrel=1
arch=('any')
url="https://github.com/ahupp/python-magic"
license=('Expat')
depends=('python')
makedepends=('python-setuptools' 'quilt')
provides=('python-magic')
source=("https://github.com/ahupp/${pkgname}/archive/refs/tags/${pkgver}.tar.gz"
        "series"
        "2021-01-16.locale-in-tests.patch")
sha512sums=('3927958a6957177d1a6e8bcbbb3723f489018f9037b619bbf7478ab68ba2ddd52d9a0caf18e6a73671e8e5e1cb8a9efb957756ba9547a7dd66ab6ba293f37826'
            '60eeda5905771fed5a73a4ba42fdb7fcadda2c4c4a709b29f8f0a4c196265ab088e78760e3a7b07a648ae31809a9a60bb9fec6f8dbcbbd2936db461b064fff1a'
            '1ebbe0b8323f6e337d3e9181add1db0490ecc3d135829d7a2573ed50c5066dc74d7ff2345d38f1e071906687889226fd50133b7e8d8911e03795fdd5e6a1bba7')

prepare() {
  cd "${pkgname}-${pkgver}"

  mkdir ./patches
  cp ${srcdir}/series ./patches
  cp ${srcdir}/*.patch ./patches

  export QUILT_PATCHES=patches
  export QUILT_REFRESH_ARGS='-p ab --no-timestamps --no-index'
  export QUILT_DIFF_ARGS='--no-timestamps'

  quilt push -av
}

package() {
  cd "${pkgname}-${pkgver}"
  python setup.py install --root="${pkgdir}" --optimize='1'

  install -D -m644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
  install -D -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
